import { GLOBAL_STORE_TYPE_STORAGE } from '../../../common/constants';
import { getCurrentPlayList } from '../../../common/service/courses-service';
import { eventBusGetter } from '../../../utils/eventbus';

Page({
    data: {
        audioInfo: {},
        audioList: []
    },
    onShow: function () {
        getCurrentPlayList({
            storageType: GLOBAL_STORE_TYPE_STORAGE
        }).then(res => {
            console.log(res);
            this.setData({
                audioList: res.data
            });
        });
    },
    handleAudio: function (e) {
        let dataset = e.currentTarget.dataset;

        eventBusGetter().$emit('eventPlay', {
            audioInfo: this.data.audioList[dataset.index]
        });
    }
});
